package com.zy.algorithm.v3.complexity

import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.zy.activity.BaseFragment
import com.zy.algorithm.v3.R

class ComplexityFragment : BaseFragment() {

    override val layout: Int
        get() = R.layout.fragment_complexity_layout


    var code: Int = 0


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        code = arguments?.getInt("code", 0) ?: 0
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val time: TextView = view.findViewById(R.id.time_complexity)
        val space: TextView = view.findViewById(R.id.space_complexity)

        when (code) {
            0 -> {
                time.text = "O(n)"
                space.text = "O(1)"
            }
            1 -> {
                time.text = "O(n)"
                space.text = "O(n)"
            }
            2 -> {
                time.text = "O(n+m)"
                space.text = "O(1)"
            }
            3 -> {
                time.text = "O(n^2)"
                space.text = "O(1)"
            }
            4 -> {
                time.text = "O(kn)"
                space.text = "O(k)"
            }
            5 -> {
                time.text = "O(kn)"
                space.text = "O(1)"
            }
            6 -> {
                time.text = "O(n)"
                space.text = "O(k)"
            }
        }
    }
}